import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'home',
    component: ()=>import(/* webpackChunkName: "home" */'../views/Home'),
    redirect: '/film',

    children: [
      
      {
        path: 'film',
        name: 'film',
        component: ()=>import(/* webpackChunkName: "film" */'../views/film/Film'),
        children:[
          {
            path:'',
            redirect: 'hotshowwing',
        
          },
          {
            path:'hotshowwing',
            name:'hotshowwing',
            component:()=>import(/* webpackChunkName: "hotshowwing" */'../views/film/children/Hotshowwing'),
          },
          {
            path:'cinema',
            name:'cinema',
            component:()=>import(/* webpackChunkName: "cinema" */'../views/film/children/Cinema'),
          },
          {
            path:'wait',
            name:'wait',
            component:()=>import(/* webpackChunkName: "wait" */'../views/film/children/Wait'),
          },
         
          {
            path:'classic',
            name:'classic',
            component:()=>import(/* webpackChunkName: "classic" */'../views/film/children/Classic'),
            children:[
              {
                path:':id',
                name:'classic-dail',
                component:()=>import(/* webpackChunkName: "classic-dail" */'../components/classic/Classic-dail'),
              }
            ]
          },
          {
            path:':id',
            name:'wait-dail',
            component:()=>import(/* webpackChunkName: "wait-dail" */'../components/wait/wait-dail'),
          },
        ],
      },
      {
        path: 'viduesmax',
        name: 'viduesmax',
        component: ()=>import(/* webpackChunkName: "viduesmax" */'../views/viduesmax/Viduesmax')
      },
      {
        path: 'viduesmin',
        name: 'viduesmin',
        component: ()=>import(/* webpackChunkName: "viduesmin" */'../views/viduesmin/Viduesmin')
      },
      {
        path:'my',
        name:'my',
        component:()=>import(/* webpackChunkName: "my" */'../views/my/My'),
        redirect:to=>{
          if(window.localStorage.getItem('register')){
            return '/my/loginSuccess'
          }else {
            return '/my/meituan'
          }
        },
        children:[
          {
            path:'loginSuccess',
            name:'loginSuccess',
            component:()=>import(/*webpackChunkName:"my"*/'../views/my/children/loginSuccess')
          },
          {
            path:'meituan',
            name:'meituan',
            component:()=>import(/*webpackChunkName:"my"*/'../views/my/children/meituanLogin')
          },
          {
            path:'phone',
            name:'phone',
            component:()=>import(/*webpackChunkName:"my"*/'../views/my/children/phoneLogin')
          },
          {
            path:'register',
            name:'register',
            component:()=>import(/*webpackChunkName:"my"*/'../views/my/children/register')
          },
        ]
      }
    ]
  },
  // {
  //   path: '**',
  //   redirect: '/home'
  // }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
